﻿using System;
using System.Data;
using System.Data.SqlClient;
namespace MLY.Reports.AdvancedReports
{


    public partial class dsAdvancedRpt
    {

    }



}

namespace MLY.Reports.AdvancedReports.dsAdvancedRptTableAdapters
{
}

namespace MLY.Reports.AdvancedReports.dsAdvancedRptTableAdapters
{


    public partial class TableOTDCustomersTableAdapter : global::System.ComponentModel.Component
    {
        public SqlCommand[] SelectCommand
        {
            get
            {
                if (this._commandCollection == null)
                {
                    this.InitCommandCollection();
                }
                return this._commandCollection;
            }
            set
            {
                this._commandCollection = value;
            }
        }
        public int FillByWhere(MLY.Reports.AdvancedReports.dsAdvancedRpt.TableOTDCustomersDataTable dataTable, string WhereExpression, string OrderByExpression)
        {
            string tempSelect = this.SelectCommand[0].CommandText;
            try
            {
                string str = string.Empty;
                if (!string.IsNullOrEmpty(WhereExpression))
                {
                    str += " WHERE " + WhereExpression;
                }

                if (!string.IsNullOrEmpty(OrderByExpression))
                {
                    str += " ORDER BY " + OrderByExpression;
                }

                this._commandCollection[0].CommandText = this._commandCollection[0].CommandText.Insert(this._commandCollection[0].CommandText.IndexOf("GROUP BY"), str);
                return this.Fill(dataTable);
            }
            catch //(Exception ex)
            {
                throw;
            }
            finally
            {
                this._commandCollection[0].CommandText = tempSelect;
            }
            //return 0;
        }
    }

    public partial class TableOTDContractorsTableAdapter : global::System.ComponentModel.Component
    {
        public SqlCommand[] SelectCommand
        {
            get
            {
                if (this._commandCollection == null)
                {
                    this.InitCommandCollection();
                }
                return this._commandCollection;
            }
            set
            {
                this._commandCollection = value;
            }
        }
        public int FillByWhere(MLY.Reports.AdvancedReports.dsAdvancedRpt.TableOTDContractorsDataTable dataTable, string WhereExpression, string OrderByExpression)
        {
            string tempSelect = this.SelectCommand[0].CommandText;
            try
            {
                string str = string.Empty;
                if (!string.IsNullOrEmpty(WhereExpression))
                {
                    str += " WHERE " + WhereExpression;
                }

                if (!string.IsNullOrEmpty(OrderByExpression))
                {
                    str += " ORDER BY " + OrderByExpression;
                }

                this._commandCollection[0].CommandText = this._commandCollection[0].CommandText.Insert(this._commandCollection[0].CommandText.IndexOf("GROUP BY"), str);
                return this.Fill(dataTable);
            }
            catch //(Exception ex)
            {
                throw;
            }
            finally
            {
                this._commandCollection[0].CommandText = tempSelect;
            }
            //return 0;
        }
    }


    public partial class TableAvgWoDurationTableAdapter : global::System.ComponentModel.Component
    {

        public SqlCommand[] SelectCommand
        {
            get
            {
                if (this._commandCollection == null)
                {
                    this.InitCommandCollection();
                }
                return this._commandCollection;
            }
            set
            {
                this._commandCollection = value;
            }
        }
        public int FillByWhere(MLY.Reports.AdvancedReports.dsAdvancedRpt.TableAvgWoDurationDataTable dataTable,
                                string WhereExpression,
                                string OrderByExpression,
                                bool ForCustomer)
        {
            int queryNum = (ForCustomer ? 2 : 1);

            string tempSelect = this.SelectCommand[queryNum].CommandText;
            try
            {
                string str = string.Empty;
                if (!string.IsNullOrEmpty(WhereExpression))
                {
                    str += " WHERE " + WhereExpression;
                }

                if (!string.IsNullOrEmpty(OrderByExpression))
                {
                    str += " ORDER BY " + OrderByExpression;
                }

                this._commandCollection[queryNum].CommandText = this._commandCollection[queryNum].CommandText.Insert(this._commandCollection[queryNum].CommandText.IndexOf("GROUP BY"), str);
                if (ForCustomer)
                    return this.FillForCustomer(dataTable);
                else
                    return this.FillForContractor(dataTable);
            }
            catch //(Exception ex)
            {
                throw;
            }
            finally
            {
                this._commandCollection[queryNum].CommandText = tempSelect;
            }
            //return 0;
        }
    }


}